// import Vue from 'vue'
// import * as api from '@/api/api'
// import { isURL } from '@/utils/validate'
// import { ACCESS_TOKEN } from '@/store/mutation-types'
// import onlineCommons from '@jeecg/antd-online-mini'

import { getAction } from '@/api/manage'

export function requestSetOptions(url,params,callback,setParams) {
  setParams = setParams || {label:'name',value:'id'};
  getAction(url,params).then(res=>{
    if(res.success){
      let options = res.data.map((item,index,arr)=>{
        let c = {label:item[setParams.label], value: item[setParams.value]}
        return c;
      });
      callback(options);
      // console.log("templateOptions="+);
    }
  });
}


export function requestSetData(url,params,callback,options) {
  options = options || {};
  getAction(url,params).then(res=>{
    if(res.success){

      let resData = res.data;
      if(options.addRoot){
        resData = [{title:'根目录',value:'0',children:resData}];
      }
      callback(resData);
      // console.log("templateOptions="+);
    }
  });
}
